package io.hxci.modules.edu.controller;

import io.hxci.common.annotation.SysLog;
import io.hxci.common.utils.PageUtils;
import io.hxci.common.utils.R;
import io.hxci.modules.edu.domain.EduSign;
import io.hxci.modules.edu.service.AttendanceService;
import io.hxci.modules.edu.service.EduCourseService;
import io.hxci.modules.edu.service.EduRecordService;
import io.hxci.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping("edu/attendance")
public class AttendanceController extends AbstractController {
    @Autowired
    private AttendanceService attendanceService;
    @Autowired
    private EduRecordService recordService;
    @RequestMapping("/query")
    public R query(@RequestParam Map<String, Object> params){
        PageUtils page = attendanceService.query(params,getUserId());
        return R.ok().put("page", page);
    }



    @RequestMapping("/options")
    public  R options(){

        List<Map> list1 =attendanceService.coptions(getUserId());
        List<Map> list2 =attendanceService.boptions(getUserId());
        return R.ok().put("c", list1).put("b", list2);
    }

    @RequestMapping("/record")
    public  R record(@RequestParam Map<String, Object> params){
        PageUtils page = recordService.record(params,getUserId());
        return R.ok().put("page", page);
    }
    @SysLog("删除上课记录")
    @RequestMapping("/delete")
    public  R delete(@RequestBody String[] id){
        recordService.delete(id);
        return R.ok();
    }



}
